<template>
  <NewMianModule :title="startT + title" num="02">
    <div class="conent">
      <div class="content_item_wrap mb" v-for="(item, index) in detailListTop" :key="index">
        <div class="content_title top-title_40">{{ item.name }}</div>
        <div class="num_wrap">
          <div class="content_num">{{ item.value }}</div>
          <div class="content_unit">{{ item.util }}</div>
        </div>
      </div>

      <div class="bottom_wrap">
        <div class="content_item_wrap" v-for="(item, index) in detailListBottom" :key="index">
          <div class="content_title top-title_40">{{ item.name }}</div>
          <div class="num_wrap">
            <div class="content_num">{{ item.value }}</div>
            <div class="content_unit">{{ item.util }}</div>
          </div>
        </div>
      </div>
    </div>
  </NewMianModule>
</template>

<script>
import NewMianModule from '../../../NewMianModule/index'
import http from '@/utils/request'
//import { rightData } from '../../../right/newOneRight/rightData.js'
export default {
  props: {
    title: {
      type: String,
      default: '',
    },
    selectedName: {
      type: String,
      default: '',
    },
    startT: {
      type: String,
      default: '',
    },
    qgData: {
      type: Object,
      default: () => {}, // es6的箭头函数
    },
  },
  components: {
    NewMianModule,
  },
  data() {
    return {
      detailListTop: [
        {
          name: '金融机构数量',
          value: 2,
          util: '家',
        },
      ],
      detailListBottom: [
        {
          name: '产品数量',
          value: 3,
          util: '个',
        },
      ],
    }
  },
  mounted() {
    this.initPage()
  },
  methods: {
    async initPage() {
      let _ = this
      try {
        let areaSign = _.selectedName === 'lishui' ? 'lishui' : 'quanGuo'
        const res1 = await http.post('/khy/showData/getOrganData?areaSign=' + areaSign)
        _.detailListBottom[0].value = res1.productNum
        _.detailListTop[0].value = res1.organNum
      } catch (e) {
        console.log(e)
      }
    },
    acculateAdd(num1, num2) {
      let r1, r2, m, c
      try {
        r1 = num1.toString().split('.')[1].length
      } catch (e) {
        r1 = 0
      }
      try {
        r2 = num2.toString().split('.')[1].length
      } catch (e) {
        r2 = 0
      }
      c = Math.abs(r1 - r2)
      m = Math.pow(10, Math.max(r1, r2))
      if (c > 0) {
        let cm = Math.pow(10, c)
        if (r1 > r2) {
          num1 = Number(num1.toString().replace('.', ''))
          num2 = Number(num2.toString().replace('.', '')) * cm
        } else {
          num1 = Number(num1.toString().replace('.', '')) * cm
          num2 = Number(num2.toString().replace('.', ''))
        }
      } else {
        num1 = Number(num1.toString().replace('.', ''))
        num2 = Number(num2.toString().replace('.', ''))
      }
      return (num1 + num2) / m
    },
  },
}
</script>

<style lang="scss" scoped>
@import '../rightBase.css';
.conent {
  width: 100%;
  height: calc(100% - 20px);
  padding-top: 20px;
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
}

.bottom_wrap {
  /*width: calc(100% - 20px);*/
  padding-right: 20px;
  display: flex;
  justify-content: space-between;
}
</style>
